# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-moto
pkgver=5.0.18
pkgrel=0
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=moto
pkgdesc="A library that allows you to easily mock out tests based on AWS infrastructure."
url="https://github.com/getmoto/moto"
# loongarch64: blocked by py3-openapi-spec-validator
arch="noarch !loongarch64"
license="Apache-2.0"
depends="
	py3-boto3
	py3-botocore
	py3-cryptography
	py3-requests
	py3-xmltodict
	py3-werkzeug
	py3-dateutil
	py3-responses
	py3-jinja2
	py3-jsonpath-ng
"
checkdepends="
	py3-pytest
	py3-coverage
	py3-pytest-cov
	py3-pytest-xdist
	py3-freezegun
	py3-pylint
	py3-flask
	py3-flask-cors
	py3-openapi-spec-validator
	py3-docker-py
"
makedepends="
	py3-setuptools
	py3-gpep517
	py3-wheel
"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/getmoto/moto/archive/refs/tags/$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"

# FIXME: some tests from test_acmpca.py fail on riscv64
case "$CARCH" in
riscv64)
	pkgver=5.0.6
	pkgrel=0
	;;
esac

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer "$builddir"/.dist/*.whl
	# tests/test_cognitoidp: missing module joserfc
	# tests/test_iotdata: missing module jsondiff
	# tests/test_xray: missing module aws_xray_sdk
	# tests/test_apigateway/test_apigateway.py: missing module joserfc
	# tests/test_appsync/test_appsync_schema.py: missing module graphql
	# tests/test_awslambda: requires do_eventsourcemappingcker
	# tests/test_batch/test_batch_jobs.py: timeout error
	# tests/test_cloudformation: missing module cfnlint + timeout error
	# tests/test_core/test_docker.py: requires docker
	# tests/test_dynamodb/test_dynamodb_statements.py: missing module py_partiql_parser
	# tests/test_events/test_events_lambdatriggers_integration.py: requires docker
	# tests/test_logs/test_integration.py: requires docker
	# tests/test_resiliencehub/test_resiliencehub.py: botocore.exceptions.ParamValidationError: Parameter validation failed
	# tests/test_s3/test_s3_lambda_integration.py: requires docker
	# tests/test_s3/test_s3_select.py: missing module py_partiql_parser
	# tests/test_secretsmanager/test_secretsmanager.py: AttributeError: 'SecretsManager' object has no attribute 'batch_get_secret_value'. Did you mean: 'get_secret_value'?
	# tests/test_sqs/test_sqs_integration.py: requires docker
	# tests/test_stepfunctions/parser: missing module antlr4
	# tests/test_resiliencehub/test_resiliencyhub_resources.py: key error: creationTime
	# tests/test_ssoadmin/test_ssoadmin.py: AttributeError: 'SSOAdmin' object has no attribute 'list_account_assignments_for_principal'. Did you mean: 'list_account_assignment_creation_status
	# tests/test_s3/{test_server.py,test_multiple_accounts_server.py}: Failed to establish a new connection: [Errno -2] Name does not resolve'
	# tests/test_dynamodb/test_dynamodb_import_table.py:  AssertionError: assert 'FAILED' == 'COMPLETED'
	.testenv/bin/python3 -m pytest -v \
		--ignore=tests/test_cognitoidp \
		--ignore=tests/test_iotdata \
		--ignore=tests/test_xray \
		--ignore=tests/test_apigateway/test_apigateway.py \
		--ignore=tests/test_appsync/test_appsync_schema.py \
		--ignore=tests/test_awslambda \
		--ignore=tests/test_batch/test_batch_jobs.py \
		--ignore=tests/test_cloudformation \
		--ignore=tests/test_core/test_docker.py \
		--ignore=tests/test_dynamodb/test_dynamodb_statements.py \
		--ignore=tests/test_events/test_events_lambdatriggers_integration.py \
		--ignore=tests/test_logs/test_integration.py \
	  	--ignore=tests/test_resiliencehub/test_resiliencehub.py \
		--ignore=tests/test_s3/test_s3_lambda_integration.py \
		--ignore=tests/test_s3/test_s3_select.py \
		--ignore=tests/test_secretsmanager/test_secretsmanager.py \
		--ignore=tests/test_sqs/test_sqs_integration.py \
		--ignore=tests/test_stepfunctions/parser \
		--ignore=tests/test_resiliencehub/test_resiliencyhub_resources.py \
		--ignore=tests/test_ssoadmin/test_ssoadmin.py \
		--ignore=tests/test_s3/test_multiple_accounts_server.py \
		--ignore=tests/test_s3/test_server.py \
		--ignore=tests/test_dynamodb/test_dynamodb_import_table.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
7873bddd60b7444935b7e072cfceda1e344487266b76790de88103d10e28531c99c3e6e7170d6af407638bea709f56db5a3ccde3f69e2ea16fb15ec436891f2b  py3-moto-5.0.18.tar.gz
"
